﻿







namespace UFIDA.U9.Cust.U9Demo.DeliverySV
{
	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.ServiceModel;
	using System.Runtime.Serialization;
	using System.IO;
	using UFSoft.UBF.Util.Context;
	using UFSoft.UBF;
	using UFSoft.UBF.Exceptions;
	using UFSoft.UBF.Service.Base ;

    [System.ServiceModel.ServiceContractAttribute(Namespace = "http://www.UFIDA.org", Name="UFIDA.U9.Cust.U9Demo.DeliverySV.ICreateDelivery")]
    public interface ICreateDelivery
    {
		[ServiceKnownType(typeof(ApplicationContext))]
		[ServiceKnownType(typeof(PlatformContext))]
		[ServiceKnownType(typeof(ThreadContext))]
		[ServiceKnownType(typeof( UFSoft.UBF.Business.BusinessException))]
		[ServiceKnownType(typeof( UFSoft.UBF.Business.EntityNotExistException))]
		[ServiceKnownType(typeof( UFSoft.UBF.Business.AttributeInValidException))]
		[ServiceKnownType(typeof(UFSoft.UBF.Business.AttrsContainerException))]
		[ServiceKnownType(typeof(UFSoft.UBF.Exceptions.MessageBase))]
			[FaultContract(typeof(UFSoft.UBF.Service.ServiceLostException))]
		[FaultContract(typeof(UFSoft.UBF.Service.ServiceException))]
		[FaultContract(typeof(UFSoft.UBF.Service.ServiceExceptionDetail))]
		[FaultContract(typeof(ExceptionBase))]
		[FaultContract(typeof(Exception))]
		[OperationContract()]
        void Do(IContext context ,out IList<MessageBase> outMessages ,System.String documentType, System.String docNO, List<UFIDA.U9.Cust.U9Demo.DeliveryBP.ResultDTOData> deliveryDTOList);
    }

    [UFSoft.UBF.Service.ServiceImplement]
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    public class CreateDeliveryStub : ServiceStubBase, ICreateDelivery
    {
        #region ICreateDelivery Members

        //[OperationBehavior]
        public void Do(IContext context ,out IList<MessageBase> outMessages, System.String documentType, System.String docNO, List<UFIDA.U9.Cust.U9Demo.DeliveryBP.ResultDTOData> deliveryDTOList)
        {
			
			ICommonDataContract commonData = CommonDataContractFactory.GetCommonData(context, out outMessages);
			DoEx(commonData, documentType, docNO, deliveryDTOList);
        }
        
        //[OperationBehavior]
        public void DoEx(ICommonDataContract commonData, System.String documentType, System.String docNO, List<UFIDA.U9.Cust.U9Demo.DeliveryBP.ResultDTOData> deliveryDTOList)
        {
			this.CommonData = commonData ;
            try
            {
                BeforeInvoke("UFIDA.U9.Cust.U9Demo.DeliverySV.CreateDelivery");                
                CreateDelivery objectRef = new CreateDelivery();
			
				objectRef.DocumentType = documentType;
				objectRef.DocNO = docNO;

				if (deliveryDTOList != null)
				{
					DeSerializeKey(deliveryDTOList);
					List<UFIDA.U9.Cust.U9Demo.DeliveryBP.ResultDTO> listDeliveryDTOList = new List<UFIDA.U9.Cust.U9Demo.DeliveryBP.ResultDTO>();
					foreach (UFIDA.U9.Cust.U9Demo.DeliveryBP.ResultDTOData obj in deliveryDTOList)
					{
						if (obj == null)
							continue;
				
						UFIDA.U9.Cust.U9Demo.DeliveryBP.ResultDTO child = new UFIDA.U9.Cust.U9Demo.DeliveryBP.ResultDTO();
						child.FromEntityData(obj);
						//值对象应该是依赖主创建的.但此处不是.可能的问题？
						listDeliveryDTOList.Add(child);
					}
					objectRef.DeliveryDTOList = listDeliveryDTOList;
				}

				//处理返回类型.
				objectRef.Do(); //没有返回值

	        }
			catch (System.Exception e)
            {
				DealException(e);
				throw;
            }
            finally
            {
				FinallyInvoke("UFIDA.U9.Cust.U9Demo.DeliverySV.CreateDelivery");
            }
        }
	#endregion
    }
}
